<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>Kwiki Formatter</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="textile.html">Text::Textile</a>&nbsp;&nbsp;>>Next: <a href="ACL.html">ACL(access control list) 的部分实现</a></p>
<h1>Kwiki Formatter</h1>
<div class='content'>
<p>Category: <a href='Modules.html'>Modules</a> &nbsp; Keywords: <b>Kwiki</b></p><p>
数几个小时前写了个 textile, 现在想写个 <a href="//www.kwiki.org/">Kwiki</a> 格式。
</p>


<p>
CPAN 中没有现成的 Kwiki 直接格式模块，但是有个实现了所有功能的模块 CGI::Kwiki::Formatter ，于是我就写了个继承这模块的子模块。
</p>


<p>
模块代码如下：

</p>
<blockquote><pre>package Text::KwikiFormatter;

use strict;

use vars qw( $VERSION );
$VERSION = '0.01';

use base qw(CGI::Kwiki::Formatter);

sub new {
   my $class = shift;
   my $self = { @_ };
   bless $self, $class;
   return $self;
}

sub wiki_link_format {
   my ($self, $text) = @_;
   my $wiki_link = qq{&lt;a href='$text.html'&gt;$text&lt;/a&gt;};
   return $wiki_link;
}

1;
</pre></blockquote>
<p>
代码很简单，除了要置换 wiki_link_format 这个格式是针对 wiki 内部词汇转换，我把它改为我自己所需要的 Eplanet 内部转换。
</p>


<p>
运用代码如下：

</p>
<blockquote><pre>use Text::KwikiFormatter;
my $formatter = Text::KwikiFormatter-&gt;new();

print $formatter-&gt;process($text);

</pre></blockquote>
<p>
Have fun! Enjoy!

</p>
<h2>Refer</h2>
<p>
<a href="//www.kwiki.org/index.cgi?KwikiFormattingRules">http://www.kwiki.org/index.cgi?KwikiFormattingRules</a>
</p>
</div>
<p><&lt;Previous: <a href="textile.html">Text::Textile</a>&nbsp;&nbsp;>>Next: <a href="ACL.html">ACL(access control list) 的部分实现</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=Kwiki%20Formatter&url=http://www.fayland.org/journal/Kwiki_formatter.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='Kwiki.html'>Kwiki 安装笔记</a> < <span class='digit'>2004-10-30 19:06:42</span> ></li></ul>
Created on <span class="digit">2005-04-14 22:42:55</span>, Last modified on <span class="digit">2005-04-14 22:56:18</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>